package com.enroll.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.enroll.dao.SubjectDao;
import com.enroll.model.Subject;
import com.enroll.util.CustomHibernateDaoSupport;

@Repository("subjectDao")
public class SubjectDaoImpl extends CustomHibernateDaoSupport implements SubjectDao {

	
	@Override
	public void save(Subject subject) {
		getHibernateTemplate().save(subject);

	}

	@Override
	public void update(Subject subject) {
		getHibernateTemplate().update(subject);

	}

	@Override
	public void delete(Subject subject) {
		getHibernateTemplate().delete(subject);

	}

	@SuppressWarnings("rawtypes")
	@Override
	public Subject findById(int id) {
		List list = getHibernateTemplate().find("from Subject where id=?",id);
		return (Subject)list.get(0);
	}


	@SuppressWarnings("unchecked")
	@Override
	public List<Subject> findAll() {
		List<Subject> subjects = getHibernateTemplate().find("from Subject");
		return subjects;
	}

}
